//
//  ChartCategoryItemView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 05.04.25.
//

import SwiftUI

struct ChartCategoryItemView: View {
    
    var item: CategoryAmount
    var body: some View {
        HStack {
            CategoryIconView(item: item.category)
            VStack {
                HStack (alignment: .bottom) {
                    Text(item.category.name.orEmpty)
                        .font(.system(size: 14))
                        .fontWeight(.medium)
                        .foregroundColor(Color.koiColorTitle)
                    Text(item.percent.toPercent())
                        .font(.system(size: 12))
                        .foregroundColor(Color.koiColorTitleSecond)
                        .padding(.bottom, 1)
                    Spacer()
                    Text(item.amount.toAmountWithSign())
                        .font(.system(size: 18))
                        .foregroundColor(Color.koiColorTitle)
                }
                ProgressView(value: item.percent).accentColor(Color.koiColorPrimary)
            }
            .padding(.leading, 10)
            .padding(.trailing, 6)
            Image("koi_ic_arrow_right")
        }
    }
}

#Preview {
    ChartCategoryItemView(item: CategoryAmount(category: AccountingCategory(name: "餐饮", icon: "linearicon://koi_rice"), amount: 100.0, percent: 0.3))
}
